package com.example.demo.controller;

import com.example.demo.service.UniversalService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("ip")
@RequiredArgsConstructor
public class IpController {

    private final UniversalService service;

    @GetMapping
    public String getIpAddress(HttpServletRequest request) {
        String ipStr = service.getIpStr(request);
        return service.getAddressByIp(ipStr);
    }
}
